# Maintainer: David Runge <dvzrv@archlinux.org>

_name=findpython
pkgname=python-findpython
pkgver=0.2.4
pkgrel=2
pkgdesc="A utility to find python versions on your system"
arch=(any)
url="https://github.com/frostming/findpython"
license=(MIT)
depends=(python-packaging)
makedepends=(python-build python-installer python-pdm-pep517 python-wheel)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('7b4ea68c07eb81b18107b5976fd5ca32220d0299f08e5c87b94e0d92f1b0f4abe146be22320c9aa46a329877f83073793cf9953d6a40a5eb09c87a9dc9d02cd5')
b2sums=('1f30682d5a68f03338ce57af8e37c89567e611142f1854baa2032eabee7f41eff3382be2a3ceaac4808db18a7ff65eb9af929c8dea16be772c4ba34f8b0ee2ea')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="test_dir" dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
